package com.travel.controller;

import com.qianfeng.util.ResultMsg;
import com.travel.entity.TbUser;
import com.travel.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/fontuser")
public class FontUserController {

    @Autowired
    UserService userService;
    /**
     * 手机号验证
     * @return
     */
    @GetMapping("/userPhene")
    public ResultMsg phone(String phone){
        return userService.sendPhone(phone);
    }

    /**
     * 邮箱验证
     * @return
     */
    @GetMapping("/userMail")
    public ResultMsg mail(String mail){
        return userService.sendMail(mail);
    }

    @PostMapping("/login1")
    public ResultMsg login1(@RequestBody Map map){
        String username= (String) map.get("userName");
        String userpass= (String) map.get("userPass");
        return userService.loginByUserNameAndUserPass(username,userpass);
    }

    @PostMapping("/getOne")
    public ResultMsg getOne(@RequestBody TbUser tbUser){
        return userService.getOne(tbUser);
    }


    /**
     * 用户注册，添加用户
     * */
    @PostMapping("/register")
    public ResultMsg register(@RequestBody TbUser userForm){
        return userService.register(userForm);
    }

}
